<!DOCTYPE html>
<html>
<head>
<!--[if lt IE 7]>
<div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
href="http://browsehappy.com">立即升级</a>
</div>
<![endif]-->
<meta charset="utf-8">
<title>
    商品详情-文具1号
</title>
<meta content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"
name="description"/>
<meta content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年" name="keywords"/>
<meta content="上海易推信息科技有限公司" name="copyright"/>
<meta content="evil_web（429391294@qq.com）" name="author"/>
<base href="<?php echo base_url(); ?>"/>
<link href="public/js/layui/css/layui.css" rel="stylesheet">
<link href="public/css/common.css" rel="stylesheet" type="text/css"/>
<link href="public/css/default.css" rel="stylesheet" type="text/css"/>
<link href="public/css/reset.css" rel="stylesheet" type="text/css"/>
<link href="public/css/header.css" rel="stylesheet" type="text/css"/>
<link href="public/css/detail.css?v=0.03" rel="stylesheet" type="text/css"/>
<link href="public/css/sameproduct.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 9]>
<script type="text/javascript" src="../public/js/html5shiv-printshiv-3.js"></script>
<![endif]-->
</link>
</meta>
</head>
<body>
    <div class="bg">
        <?php $this->
        load->view('common/header.php'); ?>
        <form id="goods_form" method="post">
            <div class="container mt30" id="content">
                <div class="my-center-container">
                    <div class="my-center-sidebar">
                        <div class="quick_position">
                            <a href="<?php echo base_url(); ?>">首页</a>>
                            <a href="<?php echo base_url('office/index'); ?>?p=<?php echo $data['cate_big_id']; ?>&c=0&b=0">
                                <?= $data['cate_big_name'] ?>
                            </a>
                            >
                            <a href="<?php echo base_url('office/index'); ?>?p=<?php echo $data['cate_big_id']; ?>&c=<?php echo $data['cate_small_id']; ?>&b=0">
                                <?= $data['cate_small_name'] ?>
                            </a>
                            >
                            <a href="<?php echo base_url('office/index'); ?>?p=<?php echo $data['cate_big_id']; ?>&c=<?php echo $data['cate_small_id']; ?>&b=<?php echo $data['brand_id']; ?>">
                                <?= $data['brand_name'] ?>
                            </a>
                            >
                            <strong>
                                <?= $data['goods_name'] ?>
                            </strong>
                        </div>
                        <div id="detail" style="width: 100%">
                            <div class="tb-detail-bd tm-clear" id="J_DetailMeta">
                                <div class="tb-property">
                                    <div class="tb-wrap">
                                        <div class="tb-detail-hd">
                                            <h1 data-spm="1000983" style="color:#4b4a4a;font-size:16px;">
                                                <?= $data['goods_name'] ?>
                                            </h1>
                                            <p style="font-size:12px;">
                                                <?= $data['goods_small_name'] ?>
                                            </p>
                                        </div>
                                        <div class="cx-box">
                                            <div class="t">
                                                <div class="t-l">
                                                    <label>
                                                        价格
                                                    </label>
                                                    <span class="fh">
                                                        ￥
                                                    </span>
                                                    <span class="price" id="J_SalePrice">

                                                    </span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="tb-key" gdata-default-id="<?= $data['goods_id'] ?>">
                                            <div class="tb-skin tb-naked">
                                                <div class="tb-sku jermyn-shi">
                                                    <?php if (isset($data['goods_atrr'][$data['goods_id']]) && count($data['goods_atrr'][$data['goods_id']])): ?>
                                                    <?php foreach ($data['goods_atrr'][$data['goods_id']] as $k => $vo): ?>
                                                        <dl class="tb-prop tm-clear property">
                                                            <dt class="tb-metatit">
                                                                <?= $vo['catName'] ?>
                                                            </dt>
                                                            <dd>
                                                                <ul class="tm-clear J_TSaleProp tb-img "
                                                                data-property="<?= $vo['catName'] ?>"
                                                                id="goods_parent_<?= $k + 1 ?>">
                                                                <?php if (isset($vo['spec']) && count($vo['spec'])): ?>
                                                                <?php foreach ($vo['spec'] as $key => $bo): ?>
                                                                    <li class="tb-txt goods_attr <?php if ($_GET['id'] == $bo['goodId'] || ($k > 0 && $key == 0) || ($key == 0 && $_GET['id'] == $data['goods_id'])): ?>tb-selected<?php endif; ?>" gdata_attr_id="<?= $bo['attrId'] ?>" gdata_goods_child_id="<?= $bo['goodId'] ?>" id="goods_child_<?= $k + 1 ?>_<?= $key ?>">
                                                                        <a style="cursor: pointer" title="<?= $bo['attrValue'] ?>">
                                                                            <span>
                                                                                <?= $bo['attrValue'] ?>
                                                                            </span>
                                                                        </a>
                                                                        <i>
                                                                        </i>

                                                                    </li>
                                                                <?php endforeach; ?>
                                                            <?php endif; ?>
                                                        </ul>
                                                    </dd>
                                                </dl>

                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                        <dl class="tb-prop tm-clear property">
                                            <dt class="tb-metatit">
                                                货号
                                            </dt>
                                            <dd style="padding-top: 4px;" class="number">
                                                <?php if($_GET['id'] == $data['goods_id']):?>
                                                    <?= $data['goods_atrr'][$data['goods_id']][0]['spec'][0]['goodId'] ?>
                                                    <?php else:?>
                                                        <?=$_GET['id']?>
                                                    <?php endif;?>

                                                </dd>
                                            </dl>
                                            <dl class="tb-amount tm-clear" style="padding-top:25px;">
                                                <!-- <dt class="tb-metatit">数量</dt> -->
                                                <dd id="J_Amount">
                                                    <span class="tb-amount-widget mui-amount-wrap">
                                                        <input class="tb-text mui-amount-input" id="count" maxlength="8" name="count" title="请输入购买量"
                                                        type="text" value="1" onkeyup="value=value.replace(/[^\d]/g,'')">
                                                        <span class="mui-amount-btn">
                                                            <span class="mui-amount-increase">
                                                                +
                                                            </span>
                                                            <span class="mui-amount-decrease">
                                                                -
                                                            </span>
                                                        </span>
                                                    </input>
                                                </span>
                                                <div class="tb-action tm-clear tb-sell">
                                                    <!--立刻购买-->
                                                    <div class="tb-btn-buy tb-btn-sku">
                                                        <a class="tb-btn-inbox focus-btn" id="J_LinkBuy" val="1"
                                                        title="点击此按钮，到下一步确认购买信息。">
                                                        <b style="background-position: 0px 0px;">
                                                            立即购买
                                                        </b>
                                                    </a>
                                                </div>
                                                <!--加入购物车-->
                                                <div class="tb-btn-basket tb-btn-sku"
                                                style="position:relative;">
                                                <a class="focus-btn"
                                                gdata-default-id="<?= $data['goods_id'] ?>" val="2"
                                                gdata-url="<?php echo base_url(); ?>cart/add"
                                                id="add_to_cart"><b
                                                style="background-position: -167px 0px;">加入购物车</b></a>
                                            </div>
                                        </div>
                                    </dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                    <div class="new-fwcn">
                        <label>
                            服务承诺
                        </label>
                        <ul class="new-fwcn-bz">
                            <li>
                                正品保障
                            </li>
                            <li>
                                增票服务
                            </li>
                            <li>
                                闪电发货
                            </li>
                            <li>
                                七天无理由退货
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="tb-gallery">
                <div class="tb-booth tb-pic tb-s310">
                    <a href="javascript:void(0);" target="_blank">
                        <img alt="惠普硒鼓（CC388AD）2个包装 黑色HP 88A" class="jqzoom"
                        rel="<?= $data['goods_image'][0]['image_big'] ?>"
                        src="<?= $data['goods_image'][0]['image_big'] ?>"
                        style="width:350px;height:350px;cursor: crosshair;"/>
                    </a>
                </div>
                <ul class="tb-thumb" id="thumblist">
                    <?php if (isset($data['goods_image']) && count($data['goods_image'])): ?>
                    <?php foreach ($data['goods_image'] as $k =>
                    $vo): ?>
                    <li class="">
                        <div class="tb-pic tb-s40">
                            <a href="javascript:void(0);">
                                <img big="<?= $vo['image_big'] ?>" class="image_small"
                                mid="<?= $vo['image_big'] ?>"
                                src="<?= $vo['image_small'] ?>"/>
                            </a>
                        </div>
                    </li>
                <?php endforeach; ?>
            <?php endif; ?>
        </ul>
    </div>
</div>
</div>
<div>
    <ul class="tabbar tm-clear" id="J_TabBar">
        <li class="g_tab tm-selected" id="tab_detail">
            <a data-index="0" hidefocus="true" href="javascript:void(0);">
                商品详情
            </a>
        </li>
    </ul>
</div>
<div style="height: 0px; margin-top: 0px; overflow: hidden; display: none;">
</div>
<div class="attributes" id="attributes">
    <div class="attributes-list" id="J_AttrList">
        <div class="tm-clear tb-hidden tm_brandAttr" id="J_BrandAttr" style="display: block;">
            <div class="name">
                品牌名称：
                <span class="J_EbrandLogo" target="_blank">
                    <?= $data['brand_name'] ?>
                </span>
            </div>
        </div>
        <p class="attr-list-hd tm-clear">
            <em>
                产品参数：
            </em>
        </p>
        <ul id="J_AttrUL">
            <li>
                品牌:
                <?= $data['brand_name'] ?>
            </li>
            <li>
                商品编码:
                <?= $data['goods_code'] ?>
            </li>
            <?php foreach ($data['noChildgoodsArr'] as $k =>
            $vo): ?>
            <li>
                <?= $vo['attr_cat_name'] ?>
                :
                <?= $vo['attr_name'] ?>
            </li>
        <?php endforeach; ?>
    </ul>
</div>
</div>
<?= $data['goods_description'] ?>
</div>
</div>
</div>
</div>
<input name="product_id" type="hidden">
</form>
<form method="post" action="<?php echo base_url(); ?>order/detail" id="submit-ids">
    <input type="hidden" id="ids" name="ids">
</form>
</body>
</html>
<?php $this->load->view('common/bottom.php'); ?>
<script charset="utf-8" src="public/js/jquery.imagezoom.min.js" type="text/javascript">
</script>
<!--<script src="js/category.js" type="text/javascript" charset="utf-8"></script>-->
<script type="text/javascript">
    $(function () {
        $(".jqzoom").imagezoom({
            xzoom: 410,
            yzoom: 410
        });
        $("#thumblist li a").hover(function () {
            $(this).parents("li").addClass("tb-thumb-show").siblings().removeClass("tb-thumb-show");
            $(".jqzoom").attr('src', $(this).find("img").attr("mid"));
            $(".jqzoom").attr('rel', $(this).find("img").attr("big"));
        });
        var good = <?php echo json_encode($data['goods_atrr'][$data['goods_id']][0]['spec'], true)?>;
        var goodid = $('.tb-selected').attr('gdata_goods_child_id');
        judge(goodid, good);
    });

    $('.image_small').mouseover(function () {
        var image_big = $(this).attr('big');
        $('.jqzoom').attr('src', image_big);
        $('.jqzoom').attr('rel', image_big);
    })
    $('.goods_attr').click(function () {
        if ($(this).hasClass('tb-selected')) {
            $(this).removeClass('tb-selected')
            $('input[name=sku_property]').val('');
        } else {
            $(this).addClass('tb-selected');
            $(this).siblings().removeClass('tb-selected');
            $('input[name=sku_property]').val('1');
            var number = $(this).attr('gdata_goods_child_id');
            if(number != ""){
                $('.number').html($(this).attr('gdata_goods_child_id'));
            }
        }
        var good = <?php echo json_encode($data['goods_atrr'][$data['goods_id']][0]['spec'], true)?>;
        var goodid = $(this).attr('gdata_goods_child_id');
        judge(goodid, good);
    })

    $('.mui-amount-increase').click(function () {
        var count = $('input[name=count]').val();
        var count = count * 1 + 1 * 1;
        $('input[name=count]').val(count);
    })
    $('.mui-amount-decrease').click(function () {
        var count = $('input[name=count]').val();
        var count = count * 1 - 1 * 1;
        if (count == 0 || count < 0) {
            return false
        }
        $('input[name=count]').val(count);
    })
    $('#count').blur(function () {
        var count = $('input[name=count]').val();
        if (count == 0 || count < 0) {
            $('input[name=count]').val(1);
        }
    })

    function judge(goodid, good) {

        $.each(good, function (i, n) {

            if (n.goodId == goodid) {
                if(n.adjust_price){
                    $('#J_SalePrice').html(n.adjust_price)
                }else{
                    $('#J_SalePrice').html(n.price)
                }
                
                $('input[name=product_id]').val(goodid);
            }
        });

    };


//     $('#add_to_cart').on('click', function () {
//         var value = $(this).attr('val');
//         var shop_id = $('input[name=product_id]').val();
//         if (shop_id == '') {
//             layer.msg('商品出错,请返回重新选择商品');
//             return false;
//         }

//         if ($('.tb-selected').length != <?=count($data['goods_atrr'][$data['goods_id']])?>) {
//             layer.msg('请选择商品的选项');
//             return false;
//         }
//         $.post(
//             $('#add_to_cart').attr('gdata-url'),
//             $('#goods_form').serialize(),
//             function (json) {
//                 if (json.code == 0) {
//                     layer.msg(json.msg);
// +                   $('.cart-num').html(parseInt($('.cart-num').html()) + parseInt($("#count").val()))
//                 } else {
//                     layer.msg(json.msg);
//                 }
//             },
//             'json'
//         )
//         return false;
//     });

//     $('#J_LinkBuy').on('click', function () {
//         var count = $("#count").val();
//         var shop_id = $('input[name=product_id]').val();
//         if (shop_id == '') {
//             layer.msg('商品出错,请返回重新选择商品');
//             return false;
//         }

//         if ($('.tb-selected').length != <?=count($data['goods_atrr'][$data['goods_id']])?>) {
//             layer.msg('请选择商品的选项');
//             return false;
//         }

//         $.post("<?php echo base_url()?>cart/add_shop_cart", {'count':count,'shop_id':shop_id}, function (res) {
//             if (res.code == 0) {
//                 // $('input[name=ids]').val(json.data);
//                 // $("#submit-ids").submit();

//                 $.post("<?php echo base_url('order/submit');?>", {ids: json.data}, function (res) {
//                     if (res.code == -2) {
//                         layer.msg(res.msg);
//                         setTimeout(function () {
//                             window.location.href = "<?php echo $this->config->item('shop_url'); ?>mMLogin.html";
//                         }, 1000)
//                     } else if (res.code == -1) {
//                         layer.msg(res.msg);
//                     } else {
//                         window.location.href = "<?php echo base_url('order/detail');?>";
//                     }
//                 });
//             } else {
//                 alert(res.msg);
//             }
//         }, "json")
//         return false;
//     });


$('#add_to_cart,#J_LinkBuy').on('click', function () {
    var value = $(this).attr('val');
    var shop_id = $('input[name=product_id]').val();
    if (shop_id == '') {
        layer.msg('商品出错,请返回重新选择商品');
        return false;
    }

    if ($('.tb-selected').length != <?=count($data['goods_atrr'][$data['goods_id']])?>) {
        layer.msg('请选择商品的选项');
        return false;
    }
    if (value == 1) {
        $.post("<?php echo base_url()?>cart/single_add_shop_cart", {
            shop_id: shop_id,
            count: $('#count').val()
        }, function (res) {
            if (res.code == 0) {
                $.post("<?php echo base_url('order/shop');?>", $('#goods_form').serialize(), function (res) {
                    if (res.code == -2) {
                        layer.msg(res.msg);
                        setTimeout(function () {
                            window.location.href = "<?php echo $this->config->item('shop_url'); ?>mMLogin.html";
                        }, 1000)
                    } else if (res.code == -1) {
                        layer.msg(res.msg);
                    } else {
                        window.location.href = "<?php echo base_url('order/detail');?>";
                    }
                });
            } else {
                alert(res.msg);
            }
        },
        'json')
    } else {
        $.post(
            $('#add_to_cart').attr('gdata-url'),
            $('#goods_form').serialize(),
            function (json) {
                layer.msg(json.msg);
                +$('.cart-num').html(parseInt($('.cart-num').html()) + parseInt($("#count").val()))
            }
            ,
            'json'
            )
    }
    return false;
});
</script>
